#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 10;

int n, m, x, y;
int cnt;
bool st[N][N];

void dfs(int x, int y, int u) {
    if (u == n * m) {
        cnt ++ ;
        return ;
    }
    
    st[x][y] = 1;
    
    int dx[8] = {-2, -1, 1, 2, 2, 1, -1, -2};
    int dy[8] = {1, 2, 2, 1, -1, -2, -2, -1};
    for (int i = 0; i < 8; ++ i) {
        int a = x + dx[i], b = y + dy[i];
        if (a >= 0 && a < n && b >= 0 && b < m && !st[a][b]) 
            dfs(a, b, u + 1);
    }
    
    st[x][y] = 0;
}

int main() {
    int T;
    cin >> T;
    
    while (T -- ) {
        scanf("%d%d%d%d", &n, &m, &x, &y);
        cnt = 0;
        dfs(x, y, 1);
        printf("%d\n", cnt);
    }
    
    return 0;
}